<?php

namespace App\Mail;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class LoanMail extends Mailable
{
    use Queueable, SerializesModels;

    private $path;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($path)
    {
        $this->path = $path;
    }

    /**
     * Description: 前一天放款数据邮件
     * Author: liuju
     * DateTime: 2019-03-13 18:05
     * @return LoanMail
     */
    public function build()
    {
        $date = Carbon::yesterday()->format('Ymd');
        $dateTime = Carbon::yesterday()->format('Y年m月d日');
        $string = $date.'借款表'.'.xlsx';
        return $this->view('mail.loan', ['str'=>$dateTime .'借款表，敬请查收'])->attach($this->path, [
            'as' => $string
        ]);
    }
}
